//
// Created by LiuYou on 2021/10/24.
//

#include <iostream>


/*
// abort - cause abnormal process termination.(导致进程异常终止。)

        void abort(void);

DESCRIPTION
       The  abort()  function  first unblocks the SIGABRT signal, and then raises that signal for the calling process (as though raise(3) was called).  This
       results in the abnormal termination of the process unless the SIGABRT signal is caught and the signal handler does not return (see longjmp(3)).
       abort() 函数首先解除对 SIGABRT 信号的阻塞，然后为调用进程发出该信号（就像调用了 raise(3) 一样）。
       这会导致进程异常终止，除非捕获到 SIGABRT 信号并且信号处理程序不返回（请参阅 longjmp(3)）。

       abort();给当前进程发送一个 SIGABRT 信号, 目的是结束当前进程, 顺便得到一个core dump文件(核心转储文件)。

       If the SIGABRT signal is ignored, or caught by a handler that returns, the abort() function will still  terminate  the  process.   It  does  this  by
       restoring the default disposition for SIGABRT and then raising the signal for a second time.
       如果 SIGABRT 信号被忽略，或被返回的处理程序捕获，abort() 函数仍将终止进程。
       它通过恢复 SIGABRT 的默认配置然后第二次提高信号来实现这一点。

RETURN VALUE
       The abort() function never returns.

 */

/*
// system - execute a shell command.(执行shell命令。)

        int system(const char *command);

DESCRIPTION
       The system() library function uses fork(2) to create a child process that executes the shell command specified in command using execl(3) as follows:
       system() 库函数使用fork(2) 创建一个子进程，该进程使用execl(3) 执行command 中指定的shell 命令，如下所示:

           execl("/bin/sh", "sh", "-c", command, (char *) NULL);

       system() returns after the command has been completed.
       system() 在命令完成后返回。

       During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored, in the process that calls system().  (These signals
       will be handled according to their defaults inside the child process that executes command.)
       命令执行过程中，在调用system()的过程中，SIGCHLD会被阻塞，SIGINT和SIGQUIT会被忽略。 （这些信号将根据它们在执行命令的子进程内的默认值进行处理。）

       If command is NULL, then system() returns a status indicating whether a shell is available on the system.
       如果 command 为 NULL，则 system() 返回一个状态，指示系统上是否有可用的 shell。

 RETURN VALUE
       The return value of system() is one of the following:
       system() 的返回值是以下之一:

       *  If command is NULL, then a nonzero value if a shell is available, or 0 if no shell is available.
       如果 command 为 NULL，那么如果有可用的 shell，则为非零值，如果没有可用的 shell，则为 0。

       *  If a child process could not be created, or its status could not be retrieved, the return value is -1 and errno is set to indicate the error.
       如果无法创建子进程，或者无法检索其状态，则返回值为 -1 并设置 errno 以指示错误。

       *  If a shell could not be executed in the child process, then the return value is as though the child shell terminated by calling _exit(2) with  the
          status 127.
       如果无法在子进程中执行 shell，则返回值就好像子 shell 通过调用状态为 127 的 _exit(2) 终止。

       *  If  all system calls succeed, then the return value is the termination status of the child shell used to execute command.  (The termination status
          of a shell is the termination status of the last command it executes.)
       如果所有系统调用都成功，则返回值是用于执行命令的子 shell 的终止状态。 （shell 的终止状态是它执行的最后一个命令的终止状态。）

       In the last two cases, the return value is a "wait status" that can be examined using the macros described in waitpid(2).  (i.e., WIFEXITED(), WEXIT‐
       STATUS(), and so on).
       在最后两种情况下，返回值是一个“等待状态”，可以使用 waitpid(2) 中描述的宏进行检查。 （即 WIFEXITED()、WEXITSTATUS() 等）。

       system() does not affect the wait status of any other children.
       system() 不会影响任何其他孩子的等待状态。

ERRORS
       system() can fail with any of the same errors as fork(2).
       system() 可能会因任何与 fork(2) 相同的错误而失败。


 */
/*
不要在发布的源码中包含 sleep(); 语句, 因为 sleep();在用的平台上是通过 alarm();和pause();封装设计出来的。

     unsigned int sleep(unsigned int seconds);

 sleep();是一个秒级别的休眠。


 在 Linux平台上, sleep();是通过 nanosleep();设计出来的, 使用是没有问题的。

// nanosleep - high-resolution sleep.(高分辨率睡眠。), 是一个系统调用。

    int nanosleep(const struct timespec *req, struct timespec *rem);

DESCRIPTION
       nanosleep()  suspends  the  execution of the calling thread until either at least the time specified in *req has elapsed, or the delivery of a signal
       that triggers the invocation of a handler in the calling thread or that terminates the process.
       nanosleep() 暂停调用线程的执行，直到至少在 req 中指定的时间已经过去，或者传递触发调用线程中处理程序调用或终止进程的信号。

       If the call is interrupted by a signal handler, nanosleep() returns -1, sets errno to EINTR, and writes the remaining time into the structure pointed
       to by rem unless rem is NULL.  The value of *rem can then be used to call nanosleep() again and complete the specified pause (but see NOTES).
       如果调用被信号处理程序中断，则 nanosleep() 返回 -1，将 errno 设置为 EINTR，并将剩余时间写入 rem 指向的结构中，除非 rem 为 NULL。
       然后可以使用 rem 的值再次调用 nanosleep() 并完成指定的暂停（但请参阅 NOTES）。

       The structure timespec is used to specify intervals of time with nanosecond precision.  It is defined as follows:
       结构 timespec 用于以纳秒精度指定时间间隔。它的定义如下:

            struct timespec {
                time_t tv_sec;        / * seconds * /
                long   tv_nsec;       / * nanoseconds * /
            };

        The value of the nanoseconds field must be in the range 0 to 999999999.
        纳秒字段的值必须在 0 到 999999999 的范围内。


        Compared  to  sleep(3)  and  usleep(3),  nanosleep() has the following advantages: it provides a higher resolution for specifying the sleep interval;
        POSIX.1 explicitly specifies that it does not interact with signals; and it makes the task of resuming a sleep that has been interrupted by a  signal
        handler easier.
        与 sleep(3) 和 usleep(3) 相比，nanosleep() 具有以下优点:
        为指定睡眠间隔提供了更高的分辨率;
        POSIX.1 明确规定它不与信号交互；它使恢复被信号处理程序中断的睡眠的任务变得更容易。

RETURN VALUE
On  successfully  sleeping for the requested interval, nanosleep() returns 0.  If the call is interrupted by a signal handler or encounters an error,
then it returns -1, with errno set to indicate the error.
 在请求的时间间隔内成功休眠后，nanosleep() 返回 0。如果调用被信号处理程序中断或遇到错误，则返回 -1，并设置 errno 以指示错误。


 // usleep - suspend execution for microsecond intervals.(暂停执行微秒间隔。)
    int usleep(useconds_t usec);


// 实现休眠还有一个函数是 select(); 但是 select();的主要目的不是实现休眠。

        int select(int nfds, fd_set *readfds, fd_set *writefds,
                  fd_set *exceptfds, struct timeval *timeout);


 */
int main(int argc, char** argv) {

    return 0;
}
